package com.mypj.base.entity.dto;

import lombok.Data;
import lombok.ToString;

@Data
@ToString
public class JsonResult<T> {

    public static final int SUCCESS = 1;
    public static final int ERROR = -1;
    public static final int CHECK = 0;

    private int code;
    private String message;
    private T data;

    public JsonResult(int code) {
        this.code = code;
        this.message = "";
        this.data = null;
    }

    public JsonResult(int code, String message) {
        this.code = code;
        this.message = message;
        this.data = null;
    }

    public JsonResult(T data) {
        this.code = JsonResult.SUCCESS;
        this.message = "";
        this.data = data;
    }

    public JsonResult(String message, T data) {
        this.code = JsonResult.SUCCESS;
        this.message = message;
        this.data = data;
    }

    public JsonResult(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
}
